<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>
 <head>
    <title>反审管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
		<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/checkback";
		var basic_WUrl="/logic/checkback";
		var basic_Title="其他出库反审";
		var type='${type}';
		var show_Width=950;
		var show_Hight=400;
		var grid ;
		var user='${user.name}';
		function createSearch(){
			 init(1,8,'100,100,100,100,100,100,100,100','25%');
			 init(2,8,'100,100,100,100,100,100,100,100','25%');
			//第一行的数据
			addCommon(0,0,"lable","反审对象单号:");
			addCommon(0,1,"txtlike","zd002BackCode");
			addCommon(0,2,"lable","出库仓库：");
			addCommon(0,3,"selectEnum","zd004WhCode","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd002Code}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,4,"lable","PI单号:");
			addCommon(0,5,"txtlike","zd003PiCode"); 
			addCommon(0,6,"lable","经办人:");
			addCommon(0,7,"txtlike","zd006Aegnt"); 
			addCommon(2,0,"lable","反审开始时间:");
			addCommon(2,1,"datestart","zd009Date"); 
			addCommon(2,2,"lable","反审结束时间:");
			addCommon(2,3,"dateend","zd009Date"); 
		}
		$(function(){
			//创建JQGRID表格
			grid = $("#table1").ligerGrid({
		        columns: [
		                  { display: '反审单据号', name: 'zd001CheckCode', width: 100},
		                  { display: '反审对象单号', name: 'zd002BackCode', width: 100},
		                  { display: '出库库仓库', name: 'zd004WhName', width: 150},
		                  { display: '状态', name: 'zd011Stauts', width: 150,render : function (item){
		                	  if(item.zd011Stauts=='SAVE'){
		                		  return '草稿';
		                	  }else if (item.zd011Stauts=='COMMIT'){
		                		  return '提交';
		                	  }else if ( item.zd011Stauts=='AUDIT'){
		                		  return '完结';
		                	  }else if (item.zd011Stauts=='RETURN'){
		                		  return '驳回';
		                	  }
		                  }},
		                  { display: '客户', name: 'zd007CustomerName', width: 150},
		                  { display: '反审时间', name: 'zd009Date', width: 150,
		                	  render: function (item){
		                		  var cdate=new Date(item.zd009Date);
		                		  return formatDate(cdate,"yyyy-MM-dd");
		                	  }
		                  },
		                  { display: 'PI单号', name: 'zd003PiCode', width: 100},
		                  { display: '制单人', name: 'zd006Aegnt',width: 150 }
		                  ],  usePager: true,pageSize:15,
		                      url : basic_Url+"/list.do?type="+type,
		                      width: '100%', height: '98%',pageSizeOptions :[15,25,35], checkbox: true,rownumbers:true,
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edittype(data);
		                       }
		                  });
			$("#pageloading").hide();
			
		});
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do?type="+type);
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		} 
		//编辑
		function edittype(data){
			var url = basic_WUrl+"/operate/edit/"+data.id+".do?type="+'${type}';
			ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
		}
		//添加
		function toAdd(){
			var url = basic_WUrl+"/operate/add/0.do?type="+type;
			ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
		}
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			var bol = false;
			if (rows==null||rows.length==0){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}else{
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName !='${user.name}'){
				 		bol = true;
					}
				}
				
				if(bol){
					$.dialog.alert('只能对本人建的单据进行删除操作!');
					return;
				}else{
					bol = false;
					for(var i=0;i<rows.length;i++){
					 	if (rows[i].zd011Stauts == 'SAVE' || rows[i].zd011Stauts =='RETURN'){
					 		bol = true;
						}
					}
					if(bol){
						del();
						bol = false;
					}else{
						$.dialog.alert('草稿或已退回状态的单据才能进行删除!');
						return;
					}
				}
			}
		}
	</script>
  </head>
<body onload="createSearch()">
   <div id="layout1">
      <div>
          <div class="panelBar">
	           <ul class="toolBar">
	             
		           <li><a class="add" onclick="toAdd()">
		           <span>添加</span></a></li>
		       			<li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
   </div>
 
</body>
</html>